package com.alibaba.mapper;

import com.alibaba.bean.Value;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

@Mapper
@Repository
public interface ValueMapper {

    @Select(value = "select r.faceValue from rank r order by r.faceValue DESC limit 9,1")
    @Results
            ({@Result(property = "faceValue",column = "faceValue")})
    float findTopValue();

    @Insert("insert into rank(userId, faceValue, gender, age, smile, emotion, skinHealth, skinStain, skinAcne, skinDarkCircle, imgUrl) values(#{userId},#{faceValue},#{gender},#{age},#{smile},#{emotion}," +
            "#{skinHealth},#{skinStain},#{skinAcne},#{skinDarkCircle},#{imgUrl})")
    @Options(useGeneratedKeys = true,keyProperty = "userId",keyColumn = "userId")
    void putAllValue(Value value);

    @Select(value = "select count(faceValue) from (select r.faceValue from rank r) AS a")
    int totalNum();

    /*@Select(value = "select t.faceValue from rank t where t.userId = #{userId} order by t.faceValue DESC limit 0,1")
    @Results
            ({@Result(property = "faceValue",column = "faceValue")})
    float findPersonalTopValue(@Param("userId") int userId);

    @Select(value = "select count(*) from (select * from rank u where u.userId=#{userId}) as a")
    int findRecords(@Param("userId") int userId);

    @Select("select u.userName from user u where u.userId = #{userId}")
    String name(@Param("userId") int userId);

    @Select("select u.avatar from user u where u.userId = #{userId}")
    String ava(@Param("userId") int userId);*/

}
